package com.example.modulepicselector.internal.loader;

import android.content.Context;
import android.net.Uri;
import android.provider.MediaStore;

import androidx.annotation.NonNull;
import androidx.loader.content.CursorLoader;

/**
 * 图片加载器
 * @author tangan
 */
public class PicLoader extends CursorLoader {

    private static final Uri URI = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

    private static final String PROJECTION[] = {
            MediaStore.Images.Media.DATA,
            MediaStore.Images.Media.SIZE,
            MediaStore.Images.Media.DISPLAY_NAME,
            MediaStore.Images.Media.DATE_ADDED,
            MediaStore.Images.Media._ID
    };

    private static final String SORT_ORDER = MediaStore.Images.Media.DATE_ADDED + " DESC";


    private PicLoader(@NonNull Context context) {
        super(context, URI, PROJECTION, null, null, SORT_ORDER);
    }

    public static CursorLoader newInstance(Context context) {

        return new PicLoader(context);
    }
}
